<%--
  Created by IntelliJ IDEA.
  User: 86187
  Date: 2021/10/21
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="resource/css/bootstrap.css">
    <script src="resource/js/jquery-3.2.1.js"></script>
    <script src="resource/js/bootstrap.js"></script>
    <script src="resource/My97DatePicker/WdatePicker.js"></script>
    <title>订单列表</title>

</head>
<body>
<form action="/listOrder" method="post">
    订单号:<input type="text" name="orderId" value="${vo.orderId}" placeholder="请输入订单号">
    <select name="orderStatus">
        <option value="">--请选择--</option>
        <c:forEach items="${statusValues}" var="s">
            <option value="${s}" ${vo.orderStatus==s?"selected":""}>${s.name}</option>
        </c:forEach>
    </select>
    金额:<input type="text" name="m1" value="${vo.m1}">---<input type="text" name="m2" value="${vo.m2}">
    时间:<input readonly="readonly" value="<fmt:formatDate value='${vo.t1}' pattern='yyyy-MM-dd HH:mm:ss' ></fmt:formatDate>" name="t1" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">--<input readonly="readonly" value="<fmt:formatDate value='${vo.t2}' pattern='yyyy-MM-dd HH:mm:ss'></fmt:formatDate>" name="t2" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
    <input type="submit" value="查询">
    <a href="toAdd"> <input type="button" value="添加"></a>
    <table class="table table-hover">
        <thead>
        <tr>
            <th scope="col">订单编号</th>
            <th scope="col">订单日期</th>
            <th scope="col">物品种类数量</th>
            <th scope="col">订单金额</th>
            <th scope="col">订单状态</th>
            <th scope="col">操作</th>
        </tr>
        </thead>
        <tbody>

        <c:forEach items="${info.list}" var="r">
            <tr>
                <td>${r.orderId}</td>
                <td>
                    <fmt:formatDate value="${r.orderTime}" pattern="yyyy-MM-dd HH-mm-ss"></fmt:formatDate>
                </td>
                <td>${r.count}</td>
                <td>${r.money}</td>
                <td>
                    <c:if test="${r.orderStatus=='WAIT'}">待支付</c:if>
                    <c:if test="${r.orderStatus=='SEND'}">发货中</c:if>
                    <c:if test="${r.orderStatus=='FISH'}">完成</c:if>
                </td>
                <td>
                    <c:if test="${r.orderStatus=='SEND' || r.orderStatus=='FISH'}">
                        <a href="toListGoods?orderId=${r.orderId}">查看</a>
                    </c:if>
                    <c:if test="${r.orderStatus=='WAIT'}">
                        <a href="toListGoods?orderId=${r.orderId}">查看</a>
                        <a href="">修改</a>
                        <a href="javascript:deleteById('${r.orderId}')">删除</a>
                    </c:if>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
    <jsp:include page="/resource/common/pages.jsp"></jsp:include>
</form>

<script>
    function deleteById(id){
        if(confirm("您确定要删除订单编号为："+id+"的数据吗？")){
            $.get(
                "/deleteById",
                {id:id},
                function (obj){
                    if(obj){
                        alert("删除成功");
                        location.reload();
                    }else{
                        alert("删除失败");
                    }
                }
            )
        }
    }
</script>
</body>
</html>